home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 22
/
Cream of the Crop 22.iso
/
bbs
/
pad321.zip
/
CHECKNUM.MH
< prev
next >
Wrap
Text File
|
1996-10-20
|
8KB
|
255 lines
#ifndef __CHECKNUM_MH
#define __CHECKNUM_MH
#ifndef __MAX_MH
#include <max.mh>
#define __MAX_MH
#endif
#ifndef __FILE_MH
#include "file.mh"
#endif
#ifndef __TIME_MH
#include "time.mh"
#endif
#ifndef __WILDCARD_MH
#include "wildcard.mh"
#endif
#ifndef __USER_MH
#include "user.mh"
#endif
#ifndef __STRING_MH
#include "string.mh"
#endif
#ifndef __SETTINGS_MH
#include "settings.mh"
#endif
#ifndef __FINDCHAR_MH
#include "findchar.mh"
#endif
#ifndef __STRIPSTR_MH
#include "stripstr.mh"
#endif
string:
phone_number, city;
// Given a phone number, this routine determines what actually
// needs to be dialed to call that number. Returns
bool checkCallBackTime (struct _time: startTime, struct _time: endTime) {
struct _time: curTime;
bool: temp;
getTime (curTime);
temp := betweenTimes (curTime, startTime, endTime);
if (temp = False) {
log (str_bad_time_log);
show (bad_time_file, str_bad_time1 + timeToString (startTime)
+ str_bad_time2 + timeToString (endTime) + str_bad_time3);
};
return temp;
}
int getNumToDial (string: filename, string: phoneNum) {
string: line, token, ldprefix, localprefix,
file;
int: fd, idx, ldstart, ldlen, localstart,
locallen, numberType, key;
struct _time:
ldStartTime,
localStartTime,
ldEndTime,
localEndTime;
numberType := DNLDLOCKOUT;
fd := open (filename, IOPEN_READ);
if (fd = -1) {
print (str_cant_open + filename + "\n");
log (str_cant_open_log + filename);
return DNLDLOCKOUT;
};
for (;;) {
readln (fd,line);
stripRightOf (line,';');
if (line [1] = '#') {
line := strtrim (line, " \t");
if (line <> "") {
idx := stridx (line, 1, ' ');
if (idx) {
token := substr (line,1,idx-1);
line := strtrim (substr (line,idx,strlen (line) - idx + 1)," \t");
}
else {
token := line;
line := "";
};
token := strlower (token);
stripStr (token,"_");
if (token = "#end") {
show (long_distance_file, str_ld_message);
log (str_ld_message_log);
return DNLDLOCKOUT;
};
if (token = "#starttime") {strToTime (line, ldStartTime);
strToTime (line, localStartTime);};
if (token = "#endtime") {strToTime (line, ldEndTime);
strToTime (line, localEndTime);};
if (token = "#lockout") numberType := DNLOCKOUT;
if (token = "#ld") numberType := DNLD;
if (token = "#ldlockout") numberType := DNLDLOCKOUT;
if (token = "#local") numberType := DNLOCAL;
if (token = "#asklocal") numberType := DNASK;
if (token = "#ldprefix") ldprefix := line;
if (token = "#ldstart") ldstart := strtoi (line);
if (token = "#ldlen") ldlen := strtoi (line);
if (token = "#localprefix") localprefix := line;
if (token = "#localstart") localstart := strtoi (line);
if (token = "#locallen") locallen := strtoi (line);
if (token = "#ldstarttime") strToTime (line, ldStartTime);
if (token = "#ldendtime"); strToTime (line, ldEndTime);
if (token = "#localstarttime") strToTime (line, localStartTime);
if (token = "#localendtime") strToTime (line, localEndTime);
if (token = "#write") print (COL_WHITE + line + "\n");
if (token = "#file") file := line;
if (token = "#city") city := line;
if (token = "#endcity") city := "";
};
}
else {
stripStr (line, " ()-\t"); // Remove formatting characters
if (matchWildcard (phoneNum, line)) { // Does the user's phone number match?
// First, ensure that the user's number type is set appropriately.
if (numberType = DNASK) { // If necessary, ask the user if his/her
key := input_list ("Yn", 0, "", // phone number is local.
str_press_yn, str_ask_local); //
if (key = 'Y') { // If the user says their phone is local,
numberType := DNLOCAL; // set the appropriate number type
} //
else numberType := DNLD; // ditto for long distance.
}; //
if ((numberType = DNLD) // If the user's phone number is LD
and (num_allow_ld = False)) { // and LD numbers are not allowed
numberType := DNLDLOCKOUT; // set the number type to LDLOCKOUT.
};
// Display the appropriate message to the user and record the appropriate
// string in the log file.
if (city <> "") print (city + "\n");
show_file (file);
if (numberType = DNLD) {
log (str_ld_ok_log);
show (ld_ok_file, str_ld_ok_message);
};
if (numberType = DNLOCAL) {
log (str_local_log);
show (local_file, str_local_message);
};
if (numberType = DNLOCKOUT) {
show (lockout_file, str_lockout_message);
log (str_lockout_log);
};
if (numberType = DNLDLOCKOUT) {
show (long_distance_file, str_ld_message);
log (str_ld_message_log);
};
// Check to make sure the user is calling at the right time of day.
if (numberType = DNLOCAL) {
if (checkCallBackTime (localStartTime, localEndTime) = False)
numberType := DNBADTIME;
}
else if (numberType = DNLD) {
if (checkCallBackTime (ldStartTime, ldEndTime) = False)
numberType := DNBADTIME;
};
// Determine the number we have to dial to reach the user.
if ((localstart = 0) or (locallen = 0) or (ldstart = 0) or (ldlen = 0)) {
log (str_phone_bounds_error_log);
};
if (numberType = DNLOCAL) {
phone_number := localprefix + substr (phoneNum, localstart, locallen);
}
else if (numberType = DNLD) {
phone_number := ldprefix + substr (phoneNum, ldstart, ldlen);
};
return numberType;
};
};
};
return DNLDLOCKOUT;
}
int phoneInUse (string: parsedPhone, Ref string: dupeName) {
long: idx;
struct _usr: u;
for (;;) {
idx := findPhone (idx,u,parsedPhone, parsedPhone);
if (idx = -1) return False;
if ((u.name <> usr.name) and (u.deleted = False)) {
if ( ( (
num_dupe_keys = False
)
or ( (
findAnyChars (u.xkeys, str_old_keys) = False
)
and (findAllChars (u.xkeys, str_new_keys))
)
)
and ( (
num_dupe_sec = False
)
or (
u.priv >= class_to_priv (str_new_sec)
)
)
) {
dupeName := u.name;
return True;
};
};
idx := idx + 1;
};
return False;
}
int checkPhone (Ref string: parsedPhone) {
int: dialType;
string: dupeName;
if (num_dupes) {
print (str_scanning_dupe);
if (phoneInUse (parsedPhone,dupeName)) {
log (str_dupe_found_log + dupeName);
show (dupe_found_file, str_dupe_found);
return DNDUPE;
};
};
dialType := getNumToDial (phone_file, parsedPhone);
return dialType;
}
#endif